--[[
    模块功能：UDP通讯
    @author zhangfenghe
    @module socket.Udp
    @license MIT
    @copyright openLuat
    @release 2023.09.04
 ]]
require "socket"
module(...,package.seeall)


--[[
方法功能：通过UDP发送信息
]]
function udp_send_msg(sendData)
    sys.taskInit(
        function ()
            if socket.isReady() then
                log.info("socket.isReady")
                local socketClient = socket.udp() --创建一个socket udp
                --配置UDP远端地址
                if socketClient~=nil and socketClient:connect("47.92.31.46","8888") then
                    log.info("socketClient.isready")
                    if string.len(sendData)>0 then  --udp发送信息
                        socketClient:send(sendData)
                    end
                    socketClient:close()    --Udp关闭
                end

            end
        end)
end
